<template>
  <div>
    账号：<input type="text" v-model="form.username" /><br />
    密码：<input type="text" v-model="form.password" /><br />
    <button @click="loginone">登录</button>
  </div>
</template>

<script>
import axios from "axios";

export default {
  name: "login",
  data() {
    return {
      form: {},
    };
  },
  methods: {
    loginone() {
      axios({ url: "login", method: "post", data: this.form }).then((res) => {
        localStorage.getItem("userid", res.userid);
        localStorage.getItem("name", res.username);
        localStorage.getItem("token", res.token);
        let pagelist = res.pagelist;
        if (pagelist.length > 0) {
          pagelist = JSON.stringify(pagelist);
        }
        localStorage.setItem("pagelist", pagelist);
      });
    },
  },
  mounted() {},
};
</script>

<style scoped></style>
